{{! corresponding files: commerce_items_edit.php & commerce_items_edit.json}}

<div class="pure-u-1">
	<header>
		<div class="pure-u-1 pure-u-md-1-2">
				<a class="returnlink current" href="{{www_path}}/commerce/items"><div class="icon icon-arw-dwn"></div><!--icon--></a><h4 class="secondary-title">&ldquo;{{name}}&rdquo;</h4>
		</div><!--pure-->
		<div class="pure-u-1 pure-u-md-1-2">
			<ul class="inline-subnav">
				<li><a class="current" href="{{www_path}}/commerce/filter/byitem/{{id}}"><span class="icon icon-search"></span> {{copy_find_orders}}</a></li>
				{{#show_beta}}<li><a href="{{www_path}}/commerce/items/send/{{id}}" class="lightboxed"><span class="icon icon-airplane"></span> Send to buyers</a></li>{{/show_beta}}
			</ul><!--inline-subnav-->
		</div><!--pure-->
	</header>

	<form accept-charset="UTF-8" method="post" id="edit_item" action="{{www_path}}/commerce/items/edit/{{id}}" name="edit_item" >
		<div class="pure-u-1 pure-u-md-1-3">
			<div class="release-cover" style="{{#image_url}}background-image:url({{image_url}});{{/image_url}}">
				<div class="release-cover-options">
					{{^image_url}}<div class="icon icon-camera placeholder"></div><!--icon-->{{/image_url}}
					<a href="{{www_path}}/assets/add/image/item/{{id}}" class="lightboxed smalltext"><span class="editcover"><span class="icon icon-camera"></span><!--icon--><strong>{{copy_add_image}}</strong></span></a>
				</div><!--release-cover-options-->
			</div><!--release-cover-->
		</div><!--pure-->

		<div class="item-general-info pure-u-1 pure-u-md-2-3">
			<input type="hidden" name="{{form_state_action}}" value="makeitso" />

			<label for="item_name">{{label_name}}</label>
			<input type="text" id="item_name" name="item_name" value="{{name}}" placeholder="A public name for the item" class="required" />

			<label for="item_description">{{label_description}}</label>
			<textarea rows="3" id="item_description" name="item_description">{{description}}</textarea>

			<div class="pure-u-1 pure-u-md-1-3">
				<label for="item_price">{{label_price}}</label>
				<input type="text" id="item_price" name="item_price" value="{{price}}" class="required number" />
			</div><!--pure-->

			<div class="pure-u-1 pure-u-md-1-3">
				<label for="item_quantity">{{label_quantity}}</label>
				{{#has_variants}}<span class="inputreadonly">{{#available_units}}{{available_units}}{{/available_units}}{{^available_units}}-1{{/available_units}}</span>{{/has_variants}}
				{{^has_variants}}<input type="text" id="item_quantity" name="item_quantity" value="{{available_units}}" class="number required" />{{/has_variants}}
			</div><!--pure-->

			<div class="pure-u-1 pure-u-md-1-3">
				<label for="item_fulfillment_asset">{{label_fulfillment_asset}}</label>
				<select id="item_fulfillment_asset" name="item_fulfillment_asset">
					{{{asset_options}}}
				</select>
			</div><!--pure-->
		</div><!--pure-->

		<div class="pure-u-1 section breaker">
			<label class="checklabel" for="item_flexible_price">
				<input type="checkbox" name="item_flexible_price" id="item_flexible_price"{{#flexible_price}} checked="checked"{{/flexible_price}} class="checkorradio" />{{label_enable}}
			</label>

			<label class="checklabel" for="item_physical">
				<input type="checkbox" name="item_physical" id="item_physical"{{#physical_fulfillment}} checked="checked"{{/physical_fulfillment}} class="checkorradio" />{{label_physical}}
			</label>
		</div><!--pure-->

		{{#physical_fulfillment}}
		<h4>Physical item options</h4>
			<div class="material drawer defaultopen">
					<h5 class="drawerhandle title hide">{{copy_show_shipping_prices}}</h5>

				<div class="drawercontent pure-u-1">
					<div class="pure-u-1" id="shippingrates" {{^physical_fulfillment}}style="display:none;"{{/physical_fulfillment}}>
						<div class="pure-u-1 pure-u-md-1-2">
							<label for="region1_first">{{label_first_shipped}} ({{region1}})</label>
							<input type="text" id="region1_first" name="region1_first" value="{{region1_first}}" class="number" placeholder="3.00" />
							<label for="region1_rest">{{label_rest_shipped}} ({{region1}})</label>
							<input type="text" id="region1_rest" name="region1_rest" value="{{region1_rest}}" class="number" placeholder="2.00" />
						</div>
						<div class="pure-u-1 pure-u-md-1-2">
							<label for="region2_first">{{label_first_shipped}} ({{region2}})</label>
							<input type="text" id="region2_first" name="region2_first" value="{{region2_first}}" class="number" placeholder="3.00" />
							<label for="region2_rest">{{label_rest_shipped}} ({{region2}})</label>
							<input type="text" id="region2_rest" name="region2_rest" value="{{region2_rest}}" class="number" placeholder="2.00" />
						</div>
					</div><!--pure-->
				</div><!--drawercontent-->

			</div><!--drawer-->
		{{/physical_fulfillment}}
	</form>

	{{#physical_fulfillment}}
		<div class="material drawer variants">
				<h5 class="drawerhandle title">{{copy_configure}}</h5>
				<div class="drawercontent">
					{{#has_variants}}
						<div class="pure-u-1">
								<form accept-charset="UTF-8" method="post" action="{{www_path}}/commerce/items/edit/{{id}}" name="edit_vars" >
									<input type="hidden" name="dovariantqty" value="makeitso" />
									<table style="width:100%;">
										<colgroup style="width:50%;"></colgroup>
										<colgroup style="width:50%;"></colgroup>
										<thead>
											<tr>
												<th scope="col">{{copy_variant_description}}</th>
												<th scope="col">{{copy_available_quantity}}</th>
											</tr>
										</thead>
										<tbody>
											{{#variants_quantities}}
												<tr>
													<td>{{formatted_name}}</td>
													<td><input type="text" id='varquantity-{{id}}' name='varquantity-{{id}}' value='{{value}}' class="required number" /></td>
												</tr>
											{{/variants_quantities}}
										</tbody>
									</table>

								
									<button type="submit">{{copy_button_save_variants}}</button>
									<a href="{{www_path}}/commerce/items/variant/{{id}}" class="button lightboxed">{{copy_reconfigure_variants}}</a>
								</form>
						</div><!--pure-->
					{{/has_variants}}
					{{^has_variants}}
						<div class="pure-u-1 pure-u-md-1-2">
								<p><strong>{{copy_add_item_variants}}</strong><br />
								{{copy_variations}}</p>
						</div><!--pure-->
						<div class="pure-u-1 pure-u-md-1-2">
								<a href="{{www_path}}/commerce/items/variant/{{id}}" class="button fullwidth lightboxed">{{copy_add_variants}}</a>
						</div><!--pure-->
					{{/has_variants}}

				</div><!--drawercontent-->
		</div><!--drawer-->
	{{/physical_fulfillment}}

	<div class="pure-u-1">
		<button class="externalsubmit" data-cash-target-form="#edit_item" type="submit">{{copy_button_save}}</button>
		<a href="{{www_path}}/commerce/items/delete/{{id}}" class="button needsconfirmation"><div class="icon icon-ban"></div><!--icon-->{{copy_button_delete}}</a>
	</div><!--pure-->

</div><!--pure-->
